package com.huike.clues.service.impl;


import com.huike.clues.domain.TbClue;
import com.huike.clues.domain.TbClueTrackRecord;
import com.huike.clues.domain.vo.ClueTrackRecordVo;
import com.huike.clues.mapper.TbClueMapper;
import com.huike.clues.mapper.TbClueTrackRecordMapper;
import com.huike.clues.service.ITbClueTrackRecordService;
import com.huike.common.core.page.TableDataInfo;
import com.huike.common.utils.bean.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 线索跟进记录Service业务层处理
 * @date 2022-04-22
 */
@Service
public class TbClueTrackRecordServiceImpl implements ITbClueTrackRecordService {

    @Autowired
    private TbClueTrackRecordMapper clueTrackRecordMapper;

    @Autowired
    private TbClueMapper clueMapper;
    /**
     * 线索跟进保存
     * @param tbClueTrackRecord
     */
    @Override
    public void saveClueTrackRecord(ClueTrackRecordVo tbClueTrackRecord) {

        TbClueTrackRecord clueTrackRecord = new TbClueTrackRecord();

        System.out.println("tbClueTrackRecord.toString() = " + tbClueTrackRecord.toString());

        BeanUtils.copyProperties(tbClueTrackRecord,clueTrackRecord,"id");

        clueTrackRecord.setType("0");
        System.out.println( clueTrackRecord.toString());
        clueTrackRecordMapper.insertClueTrackRecord(clueTrackRecord);





    }

    /**
     * 根据ID查询clue表
     * @param clueId
     * @return
     */
    @Override
    public TableDataInfo getClueById(Long clueId) {

        List<TbClue> tbClues=new ArrayList<>();
        TbClue tbClue = clueMapper.selectTbClueById(clueId);
      tbClues.add(tbClue);

        return new TableDataInfo(tbClues,tbClues.size());


    }
}
